package com.ihr360.cnb.module.payroll.service;

import com.ihr360.authority.sharing.model.vo.SimpleAuthUserResourceVo;
import com.ihr360.cnb.module.payroll.service.fllback.PayrollServiceFallback;
import com.ihr360.commons.vo.PageData;
import com.ihr360.commons.vo.ResultInfo;
import com.ihr360.entity.ApplicationApprovalEntity;
import com.ihr360.entity.StaffBankSalaryEntity;
import com.ihr360.payroll.config.system.SystemSalaryFieldEntity;
import com.ihr360.payroll.entity.setting.SalaryCompanySettingEntity;
import com.ihr360.payroll.entity.staff.CompanySalaryProfileEntity;
import com.ihr360.payroll.entity.staff.StaffPayrollInfoJournalEntity;
import com.ihr360.payroll.entity.staff.StaffSalaryEntity;
import com.ihr360.payroll.entity.staff.StaffSalaryProfileEntity;
import com.ihr360.payroll.request.StaffPayrollInfoJournalRequest;
import com.ihr360.payroll.request.StaffPayrollInfoRequest;
import com.ihr360.payroll.request.StaffPayrollInfosRequest;
import com.ihr360.payroll.request.StaffSalaryProfileSearchBody;
import com.ihr360.payroll.request.attendance.AttendanceOverTimeRequest;
import com.ihr360.payroll.request.attendance.AttendanceTakeNumberRequest;
import com.ihr360.payroll.response.StaffPayrollInfoResponse;
import com.ihr360.payroll.response.attendance.AttendanceSummaryResponse;
import com.ihr360.payroll.type.AttendanceState;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author richey
 */
@FeignClient(name = "ihr360-payroll-provider", fallback = PayrollServiceFallback.class)
public interface PayrollService {


    @GetMapping(value = "/companySalaryProfiles/init/batch", produces = MediaType.APPLICATION_JSON_VALUE)
    ResultInfo batchInitCompanySalaryProfile();

    @GetMapping(value = "/companySalaryProfiles/init", produces = MediaType.APPLICATION_JSON_VALUE)
    ResultInfo initCompanySalaryProfile(@RequestParam(value = "companyId") String companyId);

    /**
     * 只用于数据修复
     *
     * @param staffPayrollInfoRequest
     * @return
     */
    @PostMapping(value = "/staffPayrollInfoes/salaryProfile/abnormallity/adjust", produces = MediaType.APPLICATION_JSON_VALUE)
    ResultInfo abnormalityAdjustProfile(@RequestBody StaffPayrollInfoRequest staffPayrollInfoRequest);


    @PostMapping(value = "/staffPayrollInfoes/salaryProfile/wrapper/update", produces = MediaType.APPLICATION_JSON_VALUE)
    ResultInfo adjustSalaryProfileWrapper(@RequestBody StaffPayrollInfosRequest infos);

    @GetMapping(value = "/staffPayrollInfoes/staffIds/probationReview", produces = MediaType.APPLICATION_JSON_VALUE)
    List<String> probationReviewStaffIdsFromIrs(@RequestParam(value = "companyId") String companyId);

    @GetMapping(value = "/syncedBasicStaffInfoes/companyIds/list", produces = MediaType.APPLICATION_JSON_VALUE)
    List<String> getAllCompanyIds();

    /**
     * 根据薪资字典编码获取薪资字段
     *
     * @param fieldCode
     * @return
     */
    @GetMapping(value = "/systemSalaryFields/fieldCode")
    SystemSalaryFieldEntity getBasicSalaryField(@RequestParam(value = "fieldCode") String fieldCode);

    /**
     * 获取公司已经存在员工薪资数据的员工id
     */
    @GetMapping(value = "/staffPayrollInfoes/staffIds")
    List<String> findStaffIdsForExistSalaryProfile(@RequestParam(value = "companyId") String companyId);

    @PostMapping(value = "/attendanceSummaryReport/takeNumber/summary", produces = MediaType.APPLICATION_JSON_VALUE)
    AttendanceSummaryResponse attendanceTakeNumber(@RequestBody AttendanceTakeNumberRequest takeNumberRequest);

    @PostMapping(value = "/attendanceSummaryReport/takeNumber/monthlyReport", produces = MediaType.APPLICATION_JSON_VALUE)
    void takeNumberMonthlyReport(@RequestBody AttendanceTakeNumberRequest takeNumberRequest);

    @GetMapping(value = "/attendanceSummaryReport/lockAttendanceState")
    AttendanceOverTimeRequest lockAttendanceState(@RequestParam(value = "summaryId") Long summaryId, @RequestParam(value = "state") AttendanceState state);

    @GetMapping(value = "/attendanceSummaryReport/deleteSummary")
    AttendanceOverTimeRequest rollBackAttendanceSummaryData(@RequestParam(value = "summaryId") Long summaryId);


    @GetMapping(value = "/attendanceSummaryReport/rollBackState")
    AttendanceOverTimeRequest rollBackState(@RequestParam(value = "summaryId") Long summaryId,@RequestParam(value = "state") AttendanceState state);


    /**
     * 获取公司薪资档案id
     *
     * @param companyId
     * @return
     */
    @GetMapping(value = "/companySalaryProfiles/getByCompanyId")
    CompanySalaryProfileEntity findCompanySalaryProfileId(@RequestParam(value = "companyId") String companyId);

    /**
     * 获取员工薪资档案
     *
     * @param staffId
     * @return
     */
    @GetMapping("/staffPayrollInfoes/list")
    List<StaffSalaryProfileEntity> getStaffSalaryProfiles(@RequestParam(value = "staffId") String staffId, @RequestParam(value = "companyId") String companyId);


    @PostMapping(value = "/staffPayrollInfoes/save")
    boolean saveStaffSalaryProfiles(@RequestBody List<StaffSalaryProfileEntity> toSave);

    @PostMapping(value = "/staffPayrollInfoJournals/save")
    boolean saveStaffSalaryProfileJournals(@RequestBody List<StaffPayrollInfoJournalEntity> journalToSave);

    @PostMapping(value = "/staffPayrollInfoes/staffSalaryInfo/save")
    void saveStaffSalaryInfo(@RequestBody StaffSalaryEntity staffSalaryEntity);

    @GetMapping("/salary/tasks/periods/submit/approval")
    void saveApprovalApplicationId(@RequestParam(value = "companyId") String companyId, @RequestBody ApplicationApprovalEntity response, @RequestParam(value = "id") Long id);

    @GetMapping("/authority/getResourceUsers")
    List<SimpleAuthUserResourceVo> getResourceUsers(@RequestParam(value = "companyId") String companyId,
                                                    @RequestParam(value = "bizModel") String bizModelAlias,
                                                    @RequestParam(value = "resourceId") String resourceId);

    /**
     * 员工银行卡信息数据修复使用
     */
    @PostMapping(value = "/staffPayrollInfoes/saveAllStaffSalaryInfo")
    void saveAllStaffSalaryInfo(@RequestParam(value = "companyId") String companyId, @RequestBody List<StaffBankSalaryEntity> staffBankSalaryEntityList);


    /**
     * 查询公司审批设置
     */
    @GetMapping(value = "/salaryCompanySettings/querySalaryCompanySetting")
    SalaryCompanySettingEntity querySalaryCompanySetting(@RequestParam(value = "companyId") String companyId);

    /**
     * 薪酬账期关账操作
     */
    @GetMapping(value = "/salary/tasks/periods/close")
    void closeActivePeriod(@RequestParam(value = "companyId") String companyId, @RequestParam(value = "id") Long id);


    /**
     * 获取当前生效员工薪资数据
     *
     * @param param
     * @return
     */
    @PostMapping(value = "/staffPayrollInfoes/list/currentEffective")
    StaffPayrollInfoResponse getCurrentEffective(@RequestBody StaffSalaryProfileSearchBody param);

    @PostMapping(value = "/staffPayrollInfoJournals/list/authDatas")
    public PageData<StaffPayrollInfoJournalEntity> findAllAuthJournals(@RequestBody StaffPayrollInfoJournalRequest param) ;


}
